package com.snj.test2509;

import java.nio.file.Path;
import java.nio.file.Paths;

public class FileNameExtractor {
    public static void main(String[] args) {
        String filePath = "D:\\downloadAll\\file/生产仓盘点及处置情况统计表.xlsx";
        String fileName = extractFileName(filePath);
        System.out.println("提取的文件名: " + fileName);
    }

    public static String extractFileName(String filePath) {
        Path path = Paths.get(filePath);
        String fileNameWithExtension = path.getFileName().toString(); // 获取文件名（带扩展名）
        int lastDotIndex = fileNameWithExtension.lastIndexOf('.');
        if (lastDotIndex != -1) {
            return fileNameWithExtension.substring(0, lastDotIndex); // 去掉扩展名
        }
        return fileNameWithExtension; // 如果没有扩展名，返回整个文件名
    }
}